package indi.zn.commons.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description:
 * @Copyright: Copyright (c) 2016

 * @author: 周楠
 * @date 2016年6月8日 下午1:22:23
 */

public class BeanToNode {
	

	public static <I, V> CommonTreeNode<I, V> toNode(V bean,NodeIDCallback<I, V> callback) {
		
		CommonTreeNode<I, V> node=new CommonTreeNode<>();
		
		callback.setPid_Id(node, bean);
		
		node.setNodeObject(bean);

		return node;
	}

	public static <I, V> List<CommonTreeNode<I, V>> toNode(List<V> beans,NodeIDCallback<I, V> callback) {

		List<CommonTreeNode<I, V>> list=new ArrayList<>();
		
		for (V v : beans) {
			CommonTreeNode<I, V> node=new CommonTreeNode<>();
			
			callback.setPid_Id(node, v);
			
			node.setNodeObject(v);
			
			list.add(node);
		}
		
		return list;
	}

}
